using LitJson;
using System.Collections.Generic;
using UnityEngine;

namespace Assets.Scripts.GDK
{
	public class gdk_load
	{
		public static void _preloadScene()
		{
		}

		public static Dictionary<string, T> loadJson<T>(string path)
		{
			string json = gdk_www.Instance.loadJson(path);
			//string json = Resources.Load<TextAsset>(path).text;
            return JsonMapper.ToObject<Dictionary<string, T>>(json);
		}

		public static GameObject loadPrefab(string id)
		{
			GameObject original = (GameObject)Resources.Load(id);
			return Object.Instantiate(original);
		}

		public static Sprite loadSprite(string url)
		{
			Texture2D texture2D = (Texture2D)Resources.Load(url);
			return Sprite.Create(texture2D, new Rect(0f, 0f, texture2D.width, texture2D.height), new Vector2(0f, 0f));
		}

		public static T loadJsonS<T>(string path)
		{
            

            string json = Resources.Load<TextAsset>(path).text;

            return JsonMapper.ToObject<T>(json);
		}
	}
}
